#define _CRT_SECURE_NO_WARNINGS 1
class Solution {
public:
    int halveArray(vector<int>& nums) {
        double ret = 0, sum = 0;
        priority_queue<double> pq;
        for (double i : nums) pq.push(i), sum += i;
        double half = sum / 2;
        while (sum > half)
        {
            double tmp = pq.top();
            sum -= tmp / 2;
            pq.pop();
            pq.push(tmp / 2);
            ret++;
        }
        return ret;
    }
};